// 导入axios
import instance from '@/utils/axios.js'

// 登录请求
export function getLogin (data) {
  return instance({
    url: '/app/v1_0/authorizations',
    method: 'POST',
    data
  })
}

// 拉黑作者
export function blacklistApi (autid) {
  return instance({
    url: '/app/v1_0/user/blacklists',
    method: 'post',
    data: {
      target: autid
    }
  })
}

// 关注用户
export function apiFollow (autid) {
  return instance({
    url: '/app/v1_0/user/followings',
    method: 'POST',
    data: {
      target: autid
    }
  })
}

// 取消关注用户
export function apiUnFollow (autid) {
  return instance({
    url: `/app/v1_0/user/followings/${autid}`,
    method: 'DELETE'
  })
}

// 获取用户自己的信息
export function apiUserself () {
  return instance({
    url: '/app/v1_0/user',
    method: 'get'
  })
}

// 获取用户个人资料
export function apiUserselfInfo () {
  return instance({
    url: '/app/v1_0/user/profile',
    method: 'get'
  })
}

// 编辑用户资料
export function apiEditUser ({ name, gender, birthday, intro }) {
  return instance({
    url: '/app/v1_0/user/profile',
    method: 'PATCH',
    data: {
      name: name,
      gender: gender,
      birthday: birthday,
      intro: intro
    }
  })
}

// 编辑用户头像
export function apiEditUpload (photo) {
  // 异步对象，在默认情况下不能提交文件信息，如果一定要提交，要用formData来传参
  var fd = new FormData()
  // 添加属性值
  fd.append('photo', photo)
  return instance({
    url: '/app/v1_0/user/photo',
    method: 'PATCH',
    data: fd
  })
}
